package tjx.Listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintStream;

//@WebServlet(name = "ListenerServlet",urlPatterns = "/listener")
public class ListenerServlet extends HttpServlet {
    protected  void service(HttpServletRequest request,HttpServletResponse response)throws  ServletException,java.io.IOException{
         //给application添加number
        ServletContext application=super.getServletContext();
        application.setAttribute("number",0);
        //构造response
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charSet=UTF-8");
        PrintStream out = new PrintStream(response.getOutputStream());
        out.println("<html>");
        out.println("<body>");
        out.println("<h1>成功</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}
